﻿using System;
using System.Globalization;
using System.Windows.Data;
using TiaoTiaoCode.AutoUpdate.ClientUI.Enums;

namespace TiaoTiaoCode.AutoUpdate.ClientUI.Converts
{
    /// <summary>
    /// 文件状态与图标转换器
    /// </summary>
    [ValueConversion(typeof(FileUpgradeState), typeof(string))]
    public class FileUpgradeStateToKindConverter : IValueConverter
    {
        /// <summary>
        /// 状态转图标
        /// </summary>
        /// <param name="value"></param>
        /// <param name="targetType"></param>
        /// <param name="parameter"></param>
        /// <param name="culture"></param>
        /// <returns></returns>
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (!(value is FileUpgradeState state)) return "CloudDownloadOutline";

            return state switch
            {
                FileUpgradeState.Wait => "CloudDownloadOutline",
                FileUpgradeState.Downloading => "Download",
                FileUpgradeState.Completed => "CheckboxMarkedCircleOutline",
                _ => "CloudDownloadOutline"
            };
        }

        /// <summary>
        /// 图标转状态，不实现
        /// </summary>
        /// <param name="value"></param>
        /// <param name="targetType"></param>
        /// <param name="parameter"></param>
        /// <param name="culture"></param>
        /// <returns></returns>
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return default!;
        }
    }
}
